package org.wtj.service.sys;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wtj.entity.ResponsePageEntity;
import org.wtj.entity.sys.SysRoleDeptConditionEntity;
import org.wtj.entity.sys.SysRoleDeptEntity;
import org.wtj.mapper.BaseMapper;
import org.wtj.mapper.sys.SysRoleDeptMapper;
import org.wtj.service.BaseService;

import java.util.List;

/**
 * 角色部门关联 服务层
 *
 * @author wang 该项目是知识星球：java突击队 的内部项目
 * @date 2025-03-06 21:50:53
 */
@Service
public class SysRoleDeptService extends BaseService<SysRoleDeptEntity,  SysRoleDeptConditionEntity> {

	@Autowired
	private SysRoleDeptMapper sysRoleDeptMapper;

	/**
     * 查询角色部门关联信息
     *
     * @param id 角色部门关联ID
     * @return 角色部门关联信息
     */
	public SysRoleDeptEntity findById(Long id) {
	    return sysRoleDeptMapper.findById(id);
	}

	/**
     * 根据条件分页查询角色部门关联列表
     *
     * @param sysRoleDeptConditionEntity 角色部门关联信息
     * @return 角色部门关联集合
     */
	public ResponsePageEntity<SysRoleDeptEntity> searchByPage(SysRoleDeptConditionEntity sysRoleDeptConditionEntity) {
		int count = sysRoleDeptMapper.searchCount(sysRoleDeptConditionEntity);
		if (count == 0) {
			return ResponsePageEntity.buildEmpty(sysRoleDeptConditionEntity);
		}
		List<SysRoleDeptEntity> dataList = sysRoleDeptMapper.searchByCondition(sysRoleDeptConditionEntity);
		return ResponsePageEntity.build(sysRoleDeptConditionEntity, count, dataList);
	}

    /**
     * 新增角色部门关联
     *
     * @param sysRoleDeptEntity 角色部门关联信息
     * @return 结果
     */
	public int insert(SysRoleDeptEntity sysRoleDeptEntity) {
	    return sysRoleDeptMapper.insert(sysRoleDeptEntity);
	}

	/**
     * 修改角色部门关联
     *
     * @param sysRoleDeptEntity 角色部门关联信息
     * @return 结果
     */
	public int update(SysRoleDeptEntity sysRoleDeptEntity) {
	    return sysRoleDeptMapper.update(sysRoleDeptEntity);
	}

	/**
     * 批量删除角色部门关联对象
     *
     * @param ids 系统ID集合
     * @return 结果
     */
	public int deleteByIds(List<Long> ids) {
		List<SysRoleDeptEntity> entities = sysRoleDeptMapper.findByIds(ids);

		SysRoleDeptEntity entity = new SysRoleDeptEntity();
		return sysRoleDeptMapper.deleteByIds(ids, entity);
	}

	@Override
	protected BaseMapper getBaseMapper() {
		return sysRoleDeptMapper;
	}

}
